diff --git a/plugin/TopMenu/HTMLMenuLeft.php b/plugin/TopMenu/HTMLMenuLeft.php index 6ba1e52ba..df405d283 100644 --- a/plugin/TopMenu/HTMLMenuLeft.php +++ b/plugin/TopMenu/HTMLMenuLeft.php @@ -1,46 +1,47 @@ + $value) { ?>

  • $value2) { ?>
  • >
  • - +?> + diff --git a/plugin/TopMenu/HTMLMenuRight.php b/plugin/TopMenu/HTMLMenuRight.php index ee2f37f92..bc17158e8 100644 --- a/plugin/TopMenu/HTMLMenuRight.php +++ b/plugin/TopMenu/HTMLMenuRight.php @@ -1,55 +1,56 @@ + $value) { ?> - + diff --git a/plugin/TopMenu/Objects/Menu.php b/plugin/TopMenu/Objects/Menu.php index b62049baa..ae59d98c9 100644 --- a/plugin/TopMenu/Objects/Menu.php +++ b/plugin/TopMenu/Objects/Menu.php @@ -1,108 +1,119 @@ 'Left', + 2=>'Top', + 3=>'Action', + 4=>'Action Custom URL Per Video'); protected $id, $menuName, $categories_id, $users_groups_id, $menu_order, $status, $position, $type, $icon, $menuSeoUrl; static function getSearchFieldsNames() { return array(); } static function getTableName() { return 'topMenu'; } function setMenuName($menuName) { $this->menuName = $menuName; } function setCategories_id($categories_id) { $this->categories_id = $categories_id; } function setUsers_groups_id($users_groups_id) { $this->users_groups_id = $users_groups_id; } function setMenu_order($menu_order) { $this->menu_order = $menu_order; } function setStatus($status) { $this->status = $status; } function setPosition($position) { $this->position = $position; } function setType($type) { $this->type = $type; } function setIcon($icon) { $this->icon = $icon; } function setmenuSeoUrl($menuSeoUrl){ $this->menuSeoUrl=$menuSeoUrl; } static function getAllActive($type=false) { global $global; $sql = "SELECT * FROM ".static::getTableName()." WHERE status = 'active' "; if(!empty($type)){ $sql .= " AND type = $type "; } $sql .= " ORDER BY menu_order "; _mysql_connect(); $res = $global['mysqli']->query($sql); $rows = array(); if ($res) { while ($row = $res->fetch_assoc()) { $rows[] = $row; } } return $rows; } function save() { global $global; if(empty($this->menuName)){ $this->menuName = 'Unknow Menu Name'; } if(empty($this->categories_id)){ $this->categories_id = 'null'; } if(empty($this->users_groups_id)){ $this->users_groups_id = 'null'; } if(empty($this->menu_order)){ $this->menu_order = 0; } if(empty($this->status)){ $this->status = "active"; } if(empty($this->position)){ $this->position = "right"; } if(empty($this->type)){ $this->type = 1; } if(empty($this->menuSeoUrl)){ $this->menuSeoUrl=$this->menuName; } $this->menuSeoUrl=$global['mysqli']->real_escape_string(preg_replace('/[^a-z0-9]+/', '_', strtolower($this->menuSeoUrl))); return parent::save(); } } diff --git a/plugin/TopMenu/TopMenu.php b/plugin/TopMenu/TopMenu.php index 14e7326d0..45cf425d8 100644 --- a/plugin/TopMenu/TopMenu.php +++ b/plugin/TopMenu/TopMenu.php @@ -1,99 +1,167 @@ Help"; return $txt.$help; } public function getName() { return "TopMenu"; } public function getUUID() { return "2e7866ed-2e02-4136-bec6-4cd90754e3a2"; } public function getPluginVersion() { return "2.1"; } public function updateScript() { global $mysqlDatabase; //update version 2.0 $sql = "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = ? AND TABLE_NAME = ? and COLUMN_NAME=?"; $res = sqlDAL::readSql($sql,"s",array($mysqlDatabase, "topMenu_items", "menuSeoUrlItem")); $menuSeoUrlItem=sqlDAL::fetchAssoc($res); if(!$menuSeoUrlItem){ sqlDal::writeSql("alter table topMenu_items add menuSeoUrlItem varchar(255) default ''"); } return true; } public function addRoutes() { global $basePath; SimpleRouter::get($basePath."/menu/{menuSeoUrlItem}", function($menuSeoUrlItem) { $_GET['menuSeoUrlItem']=$menuSeoUrlItem; require_once "plugin/TopMenu/seo.php"; },['defaultParameterRegex' => '.*']); return false; } public function getHeadCode() { global $global; $css = ''; return $css; } public function getHTMLMenuRight() { global $global; include $global['systemRootPath'] . 'plugin/TopMenu/HTMLMenuRight.php'; } public function getPluginMenu() { global $global; $filename = $global['systemRootPath'] . 'plugin/TopMenu/pluginMenu.html'; return file_get_contents($filename); } public function getHTMLMenuLeft() { global $global; include $global['systemRootPath'] . 'plugin/TopMenu/HTMLMenuLeft.php'; } public function getidBySeoUrl($menuSeoUrlItem) { global $global; $sql="select id from topMenu_items where menuSeoUrlItem= ?"; $res=sqlDal::readSql($sql, "s", array($global['mysqli']->real_escape_string($menuSeoUrlItem))); $menuId=sqlDAL::fetchAssoc($res); if(!isset($menuId['id'])) return false; return $menuId['id']; } function getPermissionsOptions(){ $permissions = array(); $permissions[] = new PluginPermissionOption(TopMenu::PERMISSION_CAN_EDIT, __("TopMenu"), __("Can edit TopMenu plugin"), 'TopMenu'); return $permissions; } static function canAdminTopMenu(){ return Permissions::hasPermission(TopMenu::PERMISSION_CAN_EDIT,'TopMenu'); } + + public function getGalleryActionButton($videos_id) { + global $global; + $obj = $this->getDataObject(); + include $global['systemRootPath'] . 'plugin/TopMenu/actionButtonGallery.php'; + } + + public function getNetflixActionButton($videos_id) { + global $global; + $obj = $this->getDataObject(); + include $global['systemRootPath'] . 'plugin/TopMenu/actionButtonNetflix.php'; + } + + public function getWatchActionButton($videos_id) { + global $global, $video; + $obj = $this->getDataObject(); + include $global['systemRootPath'] . 'plugin/TopMenu/actionButtonNetflix.php'; + } + + static function getExternalOptionName($menu_item_id){ + return "menu_url_{$menu_item_id}"; + } + + + static function setVideoMenuURL($videos_id, $menu_item_id, $url) { + $video = new Video('', '', $videos_id); + $externalOptions = _json_decode($video->getExternalOptions()); + $parameterName = self::getExternalOptionName($menu_item_id); + $externalOptions->$parameterName = $url; + $video->setExternalOptions(json_encode($externalOptions)); + return $video->save(); + } + + static function getVideoMenuURL($videos_id, $menu_item_id) { + global $_getVideoMenuURL; + if(!isset($_getVideoMenuURL)){ + $_getVideoMenuURL = array(); + } + if(!empty($_getVideoMenuURL[$videos_id])){ + return $_getVideoMenuURL[$videos_id]; + } + $video = new Video('', '', $videos_id); + + $parameterName = self::getExternalOptionName($menu_item_id); + $externalOptions = _json_decode($video->getExternalOptions()); + $_getVideoMenuURL[$videos_id] = $externalOptions->$parameterName; + return $_getVideoMenuURL[$videos_id]; + } + + public function getVideosManagerListButton() { + if (!User::canUpload()) { + return ""; + } + $menu = Menu::getAllActive(Menu::$typeActionMenuCustomURL); + if(empty($menu)){ + return ''; + } + + $obj = $this->getDataObject(); + $btn = ''; + + $btn .= ''; + + return $btn; + } + } diff --git a/plugin/TopMenu/actionButtonGallery.php b/plugin/TopMenu/actionButtonGallery.php new file mode 100644 index 000000000..d3b080a96 --- /dev/null +++ b/plugin/TopMenu/actionButtonGallery.php @@ -0,0 +1,61 @@ + + + $value) { + $menuItems = MenuItem::getAllFromMenu($value['id'], true); + foreach ($menuItems as $key2 => $value2) { + ?> +
    + class="text-primary"> + + + + + +
    + $value) { + $menuItems = MenuItem::getAllFromMenu($value['id'], true); + foreach ($menuItems as $key2 => $value2) { + $url = TopMenu::getVideoMenuURL($videos_id, $value2['id']); + if (empty($url)) { + continue; + } + ?> +
    + class="text-primary"> + + + + + +
    + + \ No newline at end of file diff --git a/plugin/TopMenu/actionButtonNetflix.php b/plugin/TopMenu/actionButtonNetflix.php new file mode 100644 index 000000000..d743cc897 --- /dev/null +++ b/plugin/TopMenu/actionButtonNetflix.php @@ -0,0 +1,58 @@ + + + $value) { + $menuItems = MenuItem::getAllFromMenu($value['id'], true); + foreach ($menuItems as $key2 => $value2) { + ?> + class="btn btn-default"> + + + + + + $value) { + $menuItems = MenuItem::getAllFromMenu($value['id'], true); + foreach ($menuItems as $key2 => $value2) { + $url = TopMenu::getVideoMenuURL($videos_id, $value2['id']); + if(empty($url)){ + continue; + } + ?> + class="btn btn-default"> + + + + + + + diff --git a/plugin/TopMenu/addVideoInfo.php b/plugin/TopMenu/addVideoInfo.php new file mode 100644 index 000000000..e48f429cd --- /dev/null +++ b/plugin/TopMenu/addVideoInfo.php @@ -0,0 +1,95 @@ + + + + + <?php echo $config->getWebSiteTitle(); ?> :: Set Info + + + + + + $value) { + $menuItems = MenuItem::getAllFromMenu($value['id'], true); + foreach ($menuItems as $key2 => $value2) { + ?> +
    +
    +

    + + + + +

    +
    +
    + +
    + +
    + + + + + + + diff --git a/plugin/TopMenu/addVideoInfoSave.json.php b/plugin/TopMenu/addVideoInfoSave.json.php new file mode 100644 index 000000000..cdcef02f6 --- /dev/null +++ b/plugin/TopMenu/addVideoInfoSave.json.php @@ -0,0 +1,38 @@ +error = true; +$obj->msg = ""; +$obj->videos_id = 0; + +$obj->videos_id = intval($_REQUEST['videos_id']); +if (empty($obj->videos_id)) { + $obj->msg = 'You cannot edit videos_id ' . $obj->videos_id; + die(json_encode($obj)); +} + +$obj->menu_item_id = intval($_REQUEST['menu_item_id']); +if (empty($obj->menu_item_id)) { + $obj->msg = 'menu_item_id is empty'; + die(json_encode($obj)); +} + +$obj->url = $_REQUEST['url']; +if (!IsValidURL($obj->url)) { + $obj->msg = 'url is invalid '.$obj->url; + die(json_encode($obj)); +} + +if (!Video::canEdit($obj->videos_id )) { + $obj->msg = 'You cannot edit videos_id ' . $obj->videos_id; + die(json_encode($obj)); +} + +$id = TopMenu::setVideoMenuURL($obj->videos_id, $obj->menu_item_id, $obj->url); + +$obj->error = empty($id); + +echo json_encode($obj); diff --git a/plugin/TopMenu/page/editor.php b/plugin/TopMenu/page/editor.php index f53552b22..131e01d9b 100644 --- a/plugin/TopMenu/page/editor.php +++ b/plugin/TopMenu/page/editor.php @@ -1,569 +1,572 @@ <?php echo __("Top Menu") . $config->getPageTitleSeparator() . $config->getWebSiteTitle(); ?>